import java.awt.*;
import java.io.*;

class CPoint extends CObject
{
	Anchor a;						

	CPoint(int type,int subtype,int x,int y)
	{
		super(type,subtype);
		a = new Anchor(x,y);
		this.color = color;
		init();
	}

	void init()
	{
		x1 = a.x;
		y1 = a.y;
	}

	boolean checkActive(int mx,int my)
	{
	    active = (x1 - fw <= mx) && (x1 + fw >= mx) && (y1 - fh <= my) && (y1 >= my);
	    return active;
	}

	void draw(Graphics g)
	{
		boolean mode = (type == MainFrame.activeType);
		g.setColor(selected ? Color.red : (mode ? color : color2));

		if (blink || !active || selected)
		{
			a.draw(g,mode);
		}
		blink = !blink;
	}

	void move(int mx,int my,int start_x,int start_y)
	{
		a.move(mx - start_x,my - start_y);
		init();
	}

	void write(DataOutputStream out) throws IOException
	{
		out.writeByte((byte)type);
		out.writeByte((byte)subtype);
		out.writeShort((short)a.x);
		out.writeShort((short)a.y);
	}

	static CObject read(DataInputStream in,int type) throws IOException
	{
		int subtype = in.readByte();
		int x = in.readShort();
		int y = in.readShort();
		return new CPoint(type,subtype,x,y);
	}
}                
